﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TRTCMain.Controls
{
    public partial class MixButton : UserControl
    {
        private bool isChecked = false;
        public delegate void CheckStatusChangedHandler(bool isChecked);
        public event CheckStatusChangedHandler CheckStatusChanged;

        public MixButton()
        {
            InitializeComponent();
            this.label.Click += HandButton_Click;
            this.pictureBox.Click += HandButton_Click;
        }

        public bool IsChecked {
            get { return this.isChecked; }
            set {
                this.isChecked = value;
                ChangeStatus(value);
            }
        }

        private void HandButton_Click(object sender, EventArgs e)
        {
            IsChecked = !IsChecked;
        }

        private void ChangeStatus(bool isChecked) {
            if (IsChecked)
            {
                this.pictureBox.Image = Properties.Resources.screen_share_normal;
                this.label.Text = "直播";
            }
            else
            {
                this.pictureBox.Image = Properties.Resources.screen_share_start;
                this.label.Text = "停止直播";
            }

            CheckStatusChanged?.Invoke(IsChecked);
        }
    }
}
